<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js?"></script>
<script type="text/javascript">
get_check = function(){
	var ids = '';
	$("#list").find("input[type='checkbox']").each(function(){
		if ($(this).is(":checked"))
		{
            if (ids)
            {
                 ids += ',';
            }
            ids += $(this).val();
		}
	});
	return ids;
}
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme: 'facebook'});
	var product_categories_data = <?=$product_categories?>;
	$(document).mselect(product_categories_data, 'product_categories_id', 'product_categories_id', "<?=(isset($_GET['product_categories_id']))?$_GET['product_categories_id']:0?>");
	$("#check_all").click(function(){
		if ($(this).is(":checked"))
		{
			$("#list input[type='checkbox']").attr("checked", true);
		}
		else
		{
			$("#list input[type='checkbox']").attr("checked", false);
		}
	});
	$("#export_check_btn").click(function(){
		var ids = get_check();
		if (ids.length == 0)
		{
			alert("请选择产品");
			return false;
		}
		$("#ids").val(ids);
		$("#action_form").attr("action", "<?=url('Online::ProductInfo/ExportCheck')?>");
		$("#action_form").submit();
	});
	$("#export_search_btn").click(function(){
		var url_arr = <?=$url_arr?>;
		window.location.href="<?=url('Online::ProductInfo/ExportSearch')?>&url_arr=" + url_arr;
	});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>&nbsp;</th>
		<th>产品编号</th>
		<td><input type="text" name="sku" size="46" value="<?=empty($_GET['sku']) ? '' : $_GET['sku']?>"/>多个sku用英文逗号隔开(例：000001,000002 )</td>
	</tr>
	<tr>
		<th>&nbsp;</th>
		<th>描述语种</th>
		<td>
		<?foreach (Q::ini('custom_flag/online_ebay_product_language') as $l):?>
		<label><input type="checkbox" name="lang[]" class="lang" value="<?=$l['value']?>" <?=isset($_GET['lang']) && in_array($l['value'], $_GET['lang']) ? 'checked="checked"' : ''?>><?=$l['name']?> </label>
		<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>&nbsp;</th>
		<th>产品分类</th>
		<td><input type="hidden" name="product_categories_id" id="product_categories_id" /></td>
	</tr>
	<tr>
		<td></td>
		<td><input type="hidden" name="is_search" value="1" /></td>
		<td><input type="submit" class="button" value="查询" /></td>
	</tr>
</table>
</form>
</fieldset>

<table width="100%" class="list_table" id="list">
	<tr>
		<th width="80">产品编号</th>
		<th width="60">产品图片</th>
		<th width="70">描述语种</th>
		<th>标题</th>
		<th width="60">操作</th>
	</tr>
	<?foreach ($product_info as $pi):?>
	<tr>
		<td><input type="checkbox" value="<?=$pi['id']?>" /> <?=$pi['number']?></td>
		<td>
			<?if (isset($pi['pic_url']) && $pi['pic_url']):?>
				<?$pretty_photo_number = 0;?>
				<?foreach ($pi['pic_url'] as $p):?>
				<a rel="pretty_photo[1]" href="<?=$p?>"><?if(!$pretty_photo_number):?><img width="50" src="<?=$p?>" /><?endif;?></a>
				<?$pretty_photo_number = 1;?>
				<?endforeach;?>
			<?endif;?>		
		</td>
		<td><?=Helper_BSS_Normal::getIniOne('online_ebay_product_language', 'value', $pi['lang'], 'name')?></td>
		<td align="left"><?=$pi['title']?></td>
		<td><a href="<?=url('Online::ProductInfo/Detail', array('number' => $pi['number'], 'product_info_id' => $pi['id']));?>">编辑</a></td>
	</tr>
	<?endforeach;?>
</table>
<?=$page?>
<table class="list_table">
	<tr>
		<td><label><input type="checkbox" id="check_all" />全选</label></td>
		<td>导出</td>
		<td>
			<input type="button" class="button" value="按勾选" id="export_check_btn" />
			<input type="button" class="button" value="按条件" id="export_search_btn" />
		</td>
	</tr>
</table>
<form id="action_form" action="" method="post">
	<input type="hidden" name="ids" value="" id="ids" />
</form>
<?php $this->_endblock();?>